package cn.vshare.service.impl;

import cn.vshare.dao.PermissionFirstDao;
import cn.vshare.entity.PermissionFirst;
import cn.vshare.service.PermissionFirstService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Service
public class PermissionFirstServiceImpl implements PermissionFirstService {

    @Resource
    private PermissionFirstDao permissionFirstDao;

    @Override
    public PermissionFirst queryById(String id) {
        return permissionFirstDao.queryById(id);
    }

    @Override
    public List<PermissionFirst> queryByName(String name) {
        return permissionFirstDao.queryByName(name);
    }

    @Override
    public List<PermissionFirst> queryByConditions1(Map<String, Object> map) {
        return permissionFirstDao.queryByConditions(map);
    }

    @Override
    public Page<PermissionFirst> queryByConditions2(Map<String, Object> map) {
        //使用分页助手,实质是拦截器
        Page page=PageHelper.startPage((int)map.get("pageNum"),(int)map.get("pageSize"));
        //多条件查询的二级权限信息列表
        List<PermissionFirst>permissionFirstList= permissionFirstDao.queryByConditions(map);
        return page;
    }

    @Override
    public int addPermissionFirst(PermissionFirst permissionFirst) {
        return permissionFirstDao.addPermissionFirst(permissionFirst);
    }

    @Override
    public int updatePermissionFirst(PermissionFirst permissionFirst) {
        return permissionFirstDao.updatePermissionFirst(permissionFirst);
    }

    @Override
    public int deletePermissionFirstById(String id) {
        return permissionFirstDao.deletePermissionFirstById(id);
    }

    @Override
    public int addSecondPermission2First(Map<String, Object> map) {
        return permissionFirstDao.addSecondPermission2First(map);
    }

    @Override
    public int updateSecondPermission2First(Map<String, Object> map) {
        return permissionFirstDao.updateSecondPermission2First(map);
    }

    @Override
    public int deleteSecondPermission2First(Map<String, Object> map) {
        return permissionFirstDao.deleteSecondPermission2First(map);
    }

    @Override
    public List<PermissionFirst> querySecondPermission2First(Map<String, Object> map) {
        return permissionFirstDao.querySecondPermission2First(map);
    }
}
